package com.salton123.soulove.sailfish.video.ui.adapter

import android.text.format.Formatter
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.salton123.soulove.app.R
import com.salton123.soulove.sailfish.db.VideoItem
import com.salton123.soulove.utils.Utils
import com.salton123.utils.ImageLoader

/**
 * Time:9/18/21 12:41 AM
 * Author:
 * Description:
 */
class VideoCompressionAdapter :
    BaseQuickAdapter<VideoItem, BaseViewHolder>(R.layout.adapter_item_recycler_fragment_list) {
    override fun convert(holder: BaseViewHolder, item: VideoItem) {
        val ivCardContent = holder.getView<ImageView>(R.id.ivThumbnail)
        ImageLoader.loadImage(ivCardContent, item.filePath)
        holder.setText(R.id.tvTitle, item.name)
            .setText(R.id.tvSize, Formatter.formatFileSize(holder.itemView.context, item.size))
            .setText(R.id.tvFrom, holder.itemView.context.getString(R.string.from) + item.dirName)
            .setText(R.id.tvPlayTime, "${Utils.formatTime(item.playPosition)}/${Utils.formatTime(item.duration)}")
        addChildClickViewIds(R.id.tvMore)
    }
}